package com.ruoyi.goods.service.impl;

import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.goods.mapper.GoodsMapper;
import com.ruoyi.goods.domain.Goods;
import com.ruoyi.goods.service.IGoodsService;
import com.ruoyi.common.core.text.Convert;

/**
 * 商品信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-01-10
 */
@Service
public class GoodsServiceImpl implements IGoodsService 
{
    @Autowired
    private GoodsMapper goodsMapper;

    /**
     * 查询商品信息
     * 
     * @param id 商品信息主键
     * @return 商品信息
     */
    @Override
    public Goods selectGoodsById(Long id)
    {
        return goodsMapper.selectGoodsById(id);
    }

    @Override
    public List<Goods> selectGoodsByGoodsId(String good_id) {
        return goodsMapper.selectGoodsByGoodsId(good_id);
    }

    @Override
    public List<Goods> selectGoods4LeiBie() {
        List<Goods> goodsList = new ArrayList<>();
        List<String> leibeilist = goodsMapper.selectGoods4LeiBie();
        for (String s:leibeilist
             ) {
            Goods goods = new Goods();
            goods.setShangpinLeibie(s);
            goodsList.add(goods);
        }
        return goodsList;
    }

    @Override
    public Goods selectGoodsByName(String name) {
        return goodsMapper.selectGoodsByName(name);
    }

    /**
     * 查询商品信息列表
     * 
     * @param goods 商品信息
     * @return 商品信息
     */
    @Override
    public List<Goods> selectGoodsList(Goods goods)
    {
        return goodsMapper.selectGoodsList(goods);
    }

    /**
     * 新增商品信息
     * 
     * @param goods 商品信息
     * @return 结果
     */
    @Override
    public int insertGoods(Goods goods)
    {
        return goodsMapper.insertGoods(goods);
    }

    /**
     * 修改商品信息
     * 
     * @param goods 商品信息
     * @return 结果
     */
    @Override
    public int updateGoods(Goods goods)
    {
        return goodsMapper.updateGoods(goods);
    }

    /**
     * 批量删除商品信息
     * 
     * @param ids 需要删除的商品信息主键
     * @return 结果
     */
    @Override
    public int deleteGoodsByIds(String ids)
    {
        return goodsMapper.deleteGoodsByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除商品信息信息
     * 
     * @param id 商品信息主键
     * @return 结果
     */
    @Override
    public int deleteGoodsById(Long id)
    {
        return goodsMapper.deleteGoodsById(id);
    }
}
